package utils;

import org.apache.commons.codec.binary.Hex;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * Md5 加密
 * @author Administrator
 *
 */
public class Md5 {

	/**
	 * Md5 加密
	 * 
	 * @param content

	 * @return
	 */
	public static String encrypt(String content) {
		
		try {
			MessageDigest messageDigest = MessageDigest.getInstance("MD5");
			byte[] digest = messageDigest.digest(content.getBytes("utf-8"));
			return Hex.encodeHexString(digest);
		} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return null;
		
	}
}
